<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>修改数据Demo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../assets/libs/layui/css/layui.css" media="all">
</head>

<body>

    <form class="layui-form" lay-filter="example" id="uploadForm11" enctype="multipart/form-data" method="post">

        <div class="layui-form-item" style="margin-top: 20px">
            <label class="layui-form-label">电影标签编号:</label>
            <div class="layui-input-block" style="margin-right: 20px">
                <input type="text" name="movietagId" readonly="true" autocomplete="off" id="movietagId"
                    class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="margin-top: 20px">
            <label class="layui-form-label">电影标签名称:</label>
            <div class="layui-input-block" style="margin-right: 20px">
                <input type="text" name="movietagName" autocomplete="off" id="movietagName" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">电影标签简介:</label>
            <div class="layui-input-block" style="margin-right: 20px">
                <input type="text" name="movietagComm"  id="movietagComm" autocomplete="off"
                    class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="text-align: center">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" id="doSave" lay-submit=""
                    lay-filter="updataMovietag">修改</button>
                <button type="button" class="layui-btn layui-btn-primary">返回</button>
            </div>
        </div>
    </form>


    <script src="../../assets/libs/layui/layui.js" charset="utf-8"></script>
    <script src="../js/util.js" charset="utf-8"></script>
    <script>



        layui.config({
            base: '/module/'
        }).use(['jquery', 'layer', 'table', 'form', 'config'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var config = layui.config;
            var req = GetRequest();
            var no = req['editNo'];
            if (no) {
                $.ajax({
                    url: config.base_server + 'GetmovietagById?editNo=' + no,
                    dataType: 'json',
                    type: 'get',
                    success: function (data) {
                        data = data.data;
                        if (!data.length) {
                            return;
                        }
                        $('#movietagId').val(data[0].movietagId);
                        $('#movietagName').val(data[0].movietagName);
                        $('#movietagComm').val(data[0].movietagComm);
                    }

                })
            }


            //保存用户数据
            form.on('submit(updataMovietag)', function (info) {
                var data = form.val('example');
                var movietagId = data.movietagId;
                var movietagName = data.movietagName;
                var movietagComm = data.movietagComm;
                layer.load(2);
                $.ajax({
                    type: "POST",
                    url: config.base_server + "UpdatemovietagById",
                    data: {
                        movietagId, movietagName, movietagComm
                    },
                    async: false,
                    success: function (data) {
                        if (data.code == 1) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                    }

                });
                return false;
            })
           
        });
    </script>


</body>